<template>
    <div>
    <div>
      <van-nav-bar title="收藏夹" left-arrow  @click-left="onClickLeft" /> 
    </div>
    
        <div  v-for="(clGood,index) in clGoodss" :key="index">
        <van-card
          v-bind:title="clGood.clg_title"
          v-bind:desc="clGood.clg_desc"  
          v-bind:num="clGood.clg_num"
          v-bind:price="clGood.clg_price"
          :thumb="clGood.clg_img"
        >
          <div slot="footer">
            <van-button size="small" type="danger" @click="cancelcl(index)">取消收藏</van-button>
            
          </div>
        </van-card>
     
    </div>
    </div>
</template>
<script>
import { Toast } from 'vant';
import axios from "axios";
export default {
data() {
    return {
    clGoodss:[],
    nul:false
    }
  },
   computed:{

        uN(){
            return this.$store.state.uN
        },
    },
 mounted:function(){
    this.load()
 },
   methods: {
     load(){
      axios({
            method: "post",
            url: "http://localhost:3000/getUsercl",
            data: {
            uName: this.uN,
            clGoodss:this.clGoodss
            },
            headers: {
            "Content-Type": "text/plain"
            }
        }).then(result => {
             console.log(result);
             if(result.data.fileldCount==0){
               this.clGoodss=[]
               this.nul=true
             }else{
               this.clGoodss = result.data;
               this.nul=false
             }
            

        })
     },
 
 
 
 onClickLeft() {
      this.$router.go(-1)
    },



    cancelcl(index){
      axios({
            method: "post",
            url: "http://localhost:3000/cancel_Usercl",
            data: {
            uName: this.uN,
            clGoodss:this.clGoodss
            },
            headers: {
            "Content-Type": "text/plain"
            }
        }).then(result => {
             console.log(result);
            Toast.success('取消成功');
             this.load();

        })
    }
  },

  
}
</script>
<style>

</style>